<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var maximumGap = function(nums) {
    if( nums.length<2 ){
        return 0
    }
    if( nums.length==2 ){
        return Math.abs(nums[0] - nums[1])
    }
    nums.sort((a,b)=>(b-a))
    var max = nums[0] - nums[1]
    for( var i = 1 ; i<nums.length-1 ; i++ ){
        var item = nums[i] - nums[i+1]
        if( item>max ){
            max = item
        }
    }
    return max
};
var nums = [3,6,9,1]
console.log(maximumGap(nums))
    </script>
</body>
</html>